//导入request.js请求工具
import request from "@/utils/request.js";
//提供调用登录接口的函数
export const studentLoginService = (loginData) => {
  const params = new URLSearchParams();
  for (let key in loginData) {
    params.append(key, loginData[key]);
  }
  return request.post("/student/login", params);
};

export const getStudentInfoService = (username) => {
  return request.get(`/student/getStudentInfo`, {
    params: { username },
  });
};

export const listStudentService = (params) => {
  console.log("params:", params);
  return request.get("/student/page", { params: params });
};

export const addStudentService = (newStudent) => {
  return request.post("/student/add", newStudent);
};

export const updateStudentService = (updateStudent) => {
  return request.put("/student/update", updateStudent);
};

export const deleteStudentService = (studentId) => {
  return request.delete(`/student/delete/${studentId}`); //需要使用反引号才能使用嵌入式表达式
};

export const resetPasswordService = (studentId, password) => {
  return request.put(
    "/student/resetPassword?studentId=" + studentId + "&password=" + password,
  );
};
